/* Down.java
 *
 * Project/Product: GW
 *
 * Modify Information:
 * =============================================================================
 *   Author	Date       Description
 *   ----------	---------- ---------------------------------------------------
 *   Administrator	2008-2-18	First release
 *
 * Licensed Materials - Property of APEP
 * =============================================================================
 *    (C) COPYRIGHT Shanghai Auto Mart E-Procurement Co., Ltd. 2007 - 2008
 *    All Rights Reserved.
 *
 *    This software is the confidential and proprietary information of
 *    Shanghai Auto Mart E-Procurement Co., Ltd. ("Confidential Information").
 *    You shall not disclose such Confidential Information and shall use it only
 *    in accordance with the terms of the license agreement you entered into 
 *    with Shanghai Auto Mart E-Procurement Co., Ltd.
 *
 * Noties:
 * =============================================================================
 * 
 */

package system.imp;

import java.io.DataInputStream;
import java.net.URL;

import system.base.WarehouseCategory;
import framework.core.DBConnection;
import framework.core.ILoginContext;
import framework.core.LogWriter;

public class Down {
    public void doDown(DBConnection con, ILoginContext loginContext){
        String tResult="";
        DataInputStream dis = null;
        try {            
            LogWriter.info ("Begin to Down Category Data... ");
           // String tDay=DateUtil.getNextUpDay(-1);
            //文件下载
            String tDay = DateUtil.getCurrTime();
            String file = "warehousecategory";
            String Name = "download_"+tDay+file+".xls";
           // String Name = "/download_yyyymmddhhmmss_表名.xls";
            
          //  String Name1="/cat_"+tDay+".xls";
            URL url = new URL("http" + "://" + "127.0.0.1" + "/" + "file/down" + Name);
            //URL url = new URL("http" + "://" + "192.168.0.25" + "/" + "file/down" + Name);
            //URL url = new URL("http" + "://" + "192.168.0.25" + "/" + "v3/back/down" + Name);
            dis = new DataInputStream(url.openStream());
            try{
                //导入信息
                WarehouseCategory wc = new WarehouseCategory();
                //wc.
                tResult = GWFileUploadProcessor.doCatory(dis, con, loginContext);
                /*tResult = GWFileUploadProcessor.batchImportManufactureCategory(dis, con, loginContext);
            }catch(GWException e){            
                LogWriter.error(e.getMessage());            
            }*/
            //从返回的值中取得失败和成功的数据
            String tSuccess= tResult.split("-")[0];
            String tFail= tResult.split("-")[1];
            String tOutputPath = tResult.split("-")[2];

            if(Integer.parseInt(tFail)>0){
                LogWriter.error("Fail down Category output path: " + tOutputPath);
                LogWriter.error("Fail import Category count: " + tFail);
            }
            LogWriter.info("Success import Category count: " + tSuccess);
        }
        catch (Exception ex) {
            LogWriter.error("下载仓库类别时出错!");
            LogWriter.error(ex.getMessage());
        }  
        
    }catch(Exception e){
        
    }
  }

    /**{
     * 
     * @param args
     */
    public static void main(String[] args) {
    // TODO Auto-generated method stub

    }


}
